package com.liyghting.test;

/**
 * 位运算
 * 
 * @author LiYiGuang
 * @date 2018/7/24 15:43
 */
public class Weiyunsuan {

	public static void main(String[] args) {
		int value = 1;
		for (int i = 0; i < 10; i++) {
			value = 1 ^ value;
			System.out.println(value);
		}
		System.out.println(10 & 12);
		System.out.println(-6 & -2);
		System.out.println(6 & -2);
		System.out.println(12 & 8);
		String s = "1111";
		Integer integer = Integer.parseInt(s, 2);
		System.out.println(s.charAt(0) == '1');
		System.out.println(integer & 8);
		System.out.println(Integer.toBinaryString(8));
		System.out.println(Integer.parseInt("0000", 2));

		System.out.println(12 | 2);//
		// 1111 0100 1011
		// 0100 0100 0000
		// 1100 0100 1000
		// 0111 0100 0011

		System.out.println(15 ^ 4);
		System.out.println(4 ^ 4);
		System.out.println(12 ^ 4);
		System.out.println(7 ^ 4);
		// 1000 0100 0100 update
		// 0000 0100 0100 add
		// 1000 0100 1100 累加

	}
}
